<template>
  <div style="padding: 15px">
    <el-form ref="form" :rules="rules" :model="form" label-width="80px">
      <el-form-item label="名称" prop="name">
        <el-input v-model="form.name" placeholder="请输入名称" />
      </el-form-item>
      <el-form-item label="备注">
        <el-input type="textarea" v-model="form.remark" placeholder="请输入备注" />
      </el-form-item>
      <el-form-item>
        <el-button @click="funcCancel">取 消</el-button>
        <el-button type="primary" @click="funcSubmit" :disabled="isDisable">确 定</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import Vue from "vue";
import "xe-utils";
import VXETable from "vxe-table";
import "vxe-table/lib/index.css";
import { addStation } from "@/api/station";
Vue.use(VXETable);
export default {
  name: "StationAdd",
  data() {
    return {
      isDisable:false,

      form: {
        remark: "",
        name: "",
      },
      partyGroup:[],
      rules: {
        remark: [{ required: true, message: "请输入备注", trigger: "blur" }],
        name: [{ required: true, message: "请输入名称", trigger: "blur" }]
      }
    };
  },
  methods: {
    // 提交
    funcSubmit() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.isDisable = true

          const rLoading = this.openLoading();
          addStation(this.form)
            .then(response => {
              rLoading.close();
              this.$message({ message: response.msg, type: "success" });
              this.$emit("hideModel");
              this.isDisable = false

            })
            .then(() => this.$refs["form"].resetFields()).catch(() => this.isDisable = false)

        } else {
          return false;
        }
      });
    },
    // 取消
    funcCancel() {
      this.$emit("hideModel");
    }
  }
};
</script>
